package cn.lanqiao.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: yhz
 * @Date: 下午 05:03 2022/3/25
 */
@Controller
public class ScopeController {
    @RequestMapping("/testRequestByServletAPI")
    public String testRequestByServletApi(HttpServletRequest request) {
        request.setAttribute("testRequestScope", "hello");
        return "success";
    }


    @RequestMapping("/testModelA")
    public ModelAndView testModelA(HttpServletRequest request) {
        ModelAndView mav = new ModelAndView();
        mav.addObject("testRequestScope", "testModelA");
        mav.setViewName("success");
        return mav;
    }

    @RequestMapping("/testModel")
    public String testModel(Model model) {
        model.addAttribute("testRequestScope", "helloModel");
        return "success";
    }
}
